Skip to content

fix(gemini): use AfterTool instead of PostToolUse for Gemini CLI hooks#824

Merged
glittercowboy merged 1 commit intogsd-build:mainfrom
Tibsfox:fix/gemini-hook-event
Mar 2, 2026
Merged

fix(gemini): use AfterTool instead of PostToolUse for Gemini CLI hooks#824
glittercowboy merged 1 commit intogsd-build:mainfrom
Tibsfox:fix/gemini-hook-event

Conversation

@Tibsfox
Copy link
Contributor

@Tibsfox Tibsfox commented Feb 28, 2026

Summary

Gemini CLI uses AfterTool as the post-tool hook event name, not PostToolUse (which is Claude Code's event name). The installer was registering the context monitor under PostToolUse for all runtimes, causing Gemini to print an "Invalid hook event name" warning on every run and silently disabling the context monitor hook.

The comment at install.js:2034 even noted the assumption: "Gemini shares same hook system as Claude Code for now" — this turned out to be incorrect for hook event names.

Changes

  • bin/install.js: Introduce postToolEvent variable that resolves to AfterTool when runtime === 'gemini', PostToolUse otherwise. Used for both the install and registration paths.
  • bin/install.js (uninstall): Clean up both PostToolUse and AfterTool entries for backward compatibility — users who installed with the old PostToolUse key need their stale entries removed on uninstall/reinstall.
  • hooks/gsd-context-monitor.js: Runtime-aware hookEventName in output metadata (detects Gemini via GEMINI_API_KEY env var).
  • docs/context-monitor.md: Document both event names, add Gemini-specific manual registration example.

Verification

  1. Install GSD for Gemini: npx get-shit-done-cc --gemini --global
  2. Check ~/.gemini/settings.json — context monitor should be under hooks.AfterTool, not hooks.PostToolUse
  3. Run gemini -p "ping" --output-format text — no "Invalid hook event name" warning
  4. Uninstall — both AfterTool and PostToolUse entries cleaned up

Backward Compatibility

  • Existing Gemini installs with PostToolUse entries: The uninstall path now cleans up both event names, so reinstalling will migrate to AfterTool automatically.
  • Claude Code / OpenCode installs: No change — they continue using PostToolUse.

Closes #750

🤖 Generated with Claude Code

Gemini CLI uses AfterTool as the post-tool hook event name, not
PostToolUse (which is Claude Code's event name). The installer was
registering the context monitor under PostToolUse for all runtimes,
causing Gemini to print "Invalid hook event name" warnings on every
run and silently disabling the context monitor.

Changes:
- install.js: use runtime-aware event name (AfterTool for Gemini,
  PostToolUse for others) when registering context monitor hook
- install.js: uninstall cleans up both PostToolUse and AfterTool
  entries for backward compatibility with existing installs
- gsd-context-monitor.js: runtime-aware hookEventName in output
- docs/context-monitor.md: document both event names with Gemini
  example

Closes gsd-build#750

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@glittercowboy glittercowboy merged commit 9266f14 into gsd-build:main Mar 2, 2026
9 checks passed
cavanaug added a commit to cavanaug/get-shit-done that referenced this pull request Mar 3, 2026
Combined commits:
- fix(core): add --no-index to isGitIgnored for tracked file detection (gsd-build#703)
- fix(phase): add ROADMAP.md fallback to cmdPhaseComplete next-phase scan
- fix(core): prefer in-progress milestone marker in getMilestoneInfo
- fix(state): support both bold and plain field formats in state parsing
- fix(cli): preserve multi-word commit messages in CLI router
- fix(state): support both bold and plain field formats in all state.cjs functions
- fix(gemini): use AfterTool instead of PostToolUse for Gemini CLI hooks
- fix(opencode): detect runtime config directory instead of hardcoding .claude
- fix(workflow): use Skill instead of Task for auto-advance phase transitions
- fix(state): scope phase counting to current milestone
- fix(state): derive total_phases from ROADMAP when phases lack directories
- Merge pull request gsd-build#821 from Tibsfox/fix/config-and-path-corrections
- Merge pull request gsd-build#822 from Tibsfox/fix/core-lifecycle-state
- Merge pull request gsd-build#824 from Tibsfox/fix/gemini-hook-event
- Merge pull request gsd-build#825 from Tibsfox/fix/opencode-hardcoded-paths
- Merge pull request gsd-build#826 from Tibsfox/fix/auto-advance-nesting
- docs: add Copilot CLI runtime integration design doc
- docs(01-copilot-runtime): create phase plan — 3 plans for copilot runtime integration
- test(01-01): add failing tests for getCopilotSkillAdapterHeader + convertClaudeCommandToCopilotSkill
- feat(01-01): implement getCopilotSkillAdapterHeader, convertClaudeCommandToCopilotSkill, convertClaudeAgentToCopilotAgent
- test(01-02): add failing tests for installCopilotHooks + stripGsdFromCopilotHooks
- feat(01-02): implement installCopilotHooks and stripGsdFromCopilotHooks
- feat(01-03): wire copilot into arg parsing, getDirName, getGlobalDir, getConfigDirFromHome, banner, help, promptRuntime
- feat(01-03): wire copilot into install/uninstall/finishInstall + integration test
- refactor(install): collapse 4 converter helpers into 2 parameterized functions
- Revert "refactor(install): collapse 4 converter helpers into 2 parameterized functions"
- fix(copilot): restore 4 separate converter functions, fix Copilot-only bugs
- fix(copilot): omit metadata/short-description from Copilot SKILL.md frontmatter
- Merge branch 'gsd-build:main' into copilot_cli
- test(copilot): add missing agent and skill coverage
- test(copilot): add metadata/short-description stripping test for convertClaudeCommandToCopilotSkill
- remove: ➖ remove copilot planning documents
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Gemini install uses invalid PostToolUse hook event (should be AfterTool)

2 participants